﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace carpool.shenyanhong
{
    public partial class denglu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string xiaoxi = "{{\"code\":\"{0}\",\"msg\":\"{1}\"}}";
            if (!IsPostBack)
            {
                string number = Request["number"];
                string pwd = Request["pwd"];
                bool result = CheckLogin();
                if (result)
                {
                    //登录成功，跳转到主页面
                    //添加成功，返回JSON格式字符串
                    Response.Write(string.Format(xiaoxi, 1, "登录成功"));
                }
                else
                {
                    //登录失败
                    Response.Write(string.Format(xiaoxi, 0, "登录失败"));
                }
                
            }
        }
        private bool CheckLogin()
        {
            //留着
            //创建一个model
            UserInfo model = new UserInfo();
            model.Number = Request["number"];
            model.PassWord = Request["pwd"];
            //调用BLL层验证用户和密码是否存在
            return UserInfoBLL.Login(model);
        }
    }
}